package v1

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"podcast/model"
	"podcast/utills/errmsg"
)

// 查询用户是否存在
func UserExist(c *gin.Context) {
	//
}

// 添加用户
func Adduser(c *gin.Context) {
	var data model.User
	_ = c.ShouldBindJSON(&data)
	code := model.CheckUser(data.Username)
	if code == errmsg.SUCCSE {
		model.CreateUser(&data)
	}
	if code == errmsg.ERROR_USERNAME_USED {
		code = errmsg.ERROR_USERNAME_USED
	}

	c.JSON(http.StatusOK, gin.H{
		"status":  code,
		"data":    data,
		"message": errmsg.GetErrMsg(code),
	})

}

//查询单个用户

// 查询用户列表
func GetUsers(c *gin.Context) {

}

// 编辑用户
func EditUser(c *gin.Context) {

}

//删除用户

func DeleteUser(c *gin.Context) {

}
